<template>
  <el-dialog :title="showTitle" :visible.sync="show" width="1000px" @closed="closed">
    <el-descriptions size="small" border :label-style="{ whiteSpace: 'nowrap' }">
      <el-descriptions-item label="所属部门">{{ evalScore.showDeptName }}</el-descriptions-item>
      <el-descriptions-item label="项目">{{ evalScore.projectName }}</el-descriptions-item>
      <el-descriptions-item label="检查单位" v-if="evalScore.rdcType">
        <dict-tag :options="dict.type.cq_eval_rdc_type" :value="evalScore.rdcType" />
      </el-descriptions-item>
      <el-descriptions-item label="检查人员" v-if="evalScore.principalUserName">{{ evalScore.principalUserName }}</el-descriptions-item>
      <el-descriptions-item label="交付类型" v-if="evalScore.deliveryTypes">
        <dict-tag :options="dict.type.cq_eval_delivery_type" :value="evalScore.deliveryTypes" />
      </el-descriptions-item>
      <el-descriptions-item label="检查日期">{{ evalScore.checkDate }}</el-descriptions-item>
      <el-descriptions-item label="项目(检查口径)" v-if="evalScore.inpectionCaliber">{{ evalScore.inpectionCaliber }}</el-descriptions-item>
      <el-descriptions-item label="施工单位" v-if="evalScore.constructionName">{{ evalScore.constructionName }}</el-descriptions-item>
      <el-descriptions-item label="施工单位负责人" v-if="evalScore.constructionUser">{{ evalScore.constructionUser }}</el-descriptions-item>
      <el-descriptions-item label="批次" v-if="evalScore.phaseName">{{ evalScore.phaseName }}</el-descriptions-item>
      <el-descriptions-item label="标段" v-if="evalScore.section">{{ evalScore.section }}</el-descriptions-item>
      <el-descriptions-item label="项目总" v-if="evalScore.xmzName">{{ evalScore.xmzName }}</el-descriptions-item>
      <el-descriptions-item label="项目工程负责人" v-if="evalScore.xmPrincipalName">{{ evalScore.xmPrincipalName }}</el-descriptions-item>
      <el-descriptions-item label="项目经理" v-if="evalScore.xmjlName">{{ evalScore.xmjlName }}</el-descriptions-item>
      <el-descriptions-item label="集群分管领导" v-if="evalScore.colonyName">{{ evalScore.colonyName }}</el-descriptions-item>
      <el-descriptions-item label="事业部分管领导" v-if="evalScore.businessName">{{ evalScore.businessName }}</el-descriptions-item>
      <slot name="baseInfo" :info="evalScore" :cfgInfo="cfgInfo" />
      <el-descriptions-item label="锁定状态">
        <el-tag size="small" :type="evalScore.isLockout ? 'primary' : 'info'">{{ evalScore.isLockout ? '锁定' : '未锁' }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="描述" :span="3" v-if="evalScore.description">{{ evalScore.description }}</el-descriptions-item>
    </el-descriptions>

    <div v-if="showScores">
      <el-divider content-position="left">检查得分</el-divider>
      <ScoreDisplay :value="evalScore" :cfg="cfgInfo" show-throw-term show-remark />
    </div>

    <slot :info="evalScore" :cfgInfo="cfgInfo" />
  </el-dialog>
</template>
<script>
import ScoreDisplay from './ScoreDisplay'
export default {
  components: { ScoreDisplay },
  props: { showScores: { type: Boolean, default: true } },
  dicts: ['cq_eval_rdc_type', 'cq_eval_delivery_type'],
  data() {
    return {
      show: false,
      cfgInfo: {},
      evalScore: {}
    }
  },
  computed: {
    showTitle() {
      const name = this.cfgInfo?.chkitemName || '检查项得分'
      return `${name}详情`
    }
  },
  methods: {
    open({ cfgInfo, data }) {
      this.show = true
      this.cfgInfo = cfgInfo
      this.evalScore = data
    },
    closed() {
      this.cfgInfo = {}
      this.evalScore = {}
    }
  }
}
</script>
